package com.intretech.umsin.datasource;


import com.intretech.umsin.datasource.config.MybatisPlusConfig;
import com.intretech.umsin.datasource.dao.KernDAO;
import com.intretech.umsin.datasource.dao.impl.KernMyBatisDAO;
import com.intretech.umsin.datasource.handler.TimeMetaObjectHandler;
import com.intretech.umsin.datasource.util.SqlHelper;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import javax.sql.DataSource;

/**
 * @version V1.0
 * @ClassName: DataSourceAutoConfig
 * @Description: DataSourceAutoConfig 服务实现
 * @author: 李启联
 * @date: 2022-04-15 10:26
 * @Copyright: Copyright (c) 2022
 */
@Configuration
//@AutoConfigureAfter(DruidDataSource.class)
@Import(MybatisPlusConfig.class)
public class DataSourceAutoConfig {

    @Bean
    public SqlHelper getSqlHelper(DataSource dataSource){
        SqlHelper sqlHelper = new SqlHelper(dataSource);
        return sqlHelper;
    }

    @Bean
    public KernDAO getKernDAO(SqlSessionTemplate sqlSessionTemplate){
        return new KernMyBatisDAO(sqlSessionTemplate);
    }

    @Bean
    public TimeMetaObjectHandler getTimeMetaObjectHandler() {
        return new TimeMetaObjectHandler();
    }

}